/*
 * Class ItemOperate
 *
 * Version 1.0
 *
 * Thursday, August 21, 2008
 *
 * Created by Palidino76
 */

package net.com.hydroPK.net.packethandler;

import net.com.hydroPK.Engine;
import net.com.hydroPK.model.Player;
import net.com.hydroPK.util.Misc;


public class ItemOperate implements Packet {

    public int setCoordsDelay = -1;

    /**
     * Handles operating equipped items.
     *
     * @param p          The Player which the frame should be handled for.
     * @param packetId   The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        int junk = p.stream.readDWord();
        int itemId = p.stream.readUnsignedWordA();
        int itemSlot = p.stream.readUnsignedWordBigEndianA();
        if (itemSlot < 0 || itemSlot >= p.equipment.length || p.equipment[itemSlot] != itemId) {
            return;
        }
        switch (itemId) {
       case 4202:
	if (Engine.playerItems.hasPlayerItemAmount(p, 2705, 1)) {
	p.teleportTo(2110, 3915, 0);
	p.message("you have finished the second part of the Clue Scroll!");
	} else {
	p.message("nothing interesting happened.");
	}
		break;
       case 13734:
	if (Engine.playerItems.hasPlayerItemAmount(p, 995, 25000000)) {
	p.message("You Feel a strange power come over you...");
	p.teleportTo(2888, 9915, 0, 7, 0, 9603, -1, 569, 0, -1, 0);
	} else {
	p.message("please have 25M with you while you operate this Item!");
	}
	break;
       case 6737: //berserker Ring
    if (p.rights >= 1 || p.username.equalsIgnoreCase("ghost")) {
                p.specAmount = 1000;
                p.getActionSender().setConfig2(p, 300, 1000);
      //p.requestGFX(187, 0);
      p.message("you refill your Special.");
      }
      break;

       case 6570: //firecape operate
    if (p.rights >= 1 || p.username.equalsIgnoreCase("ghost")) {
      p.requestGFX(383, 0);
      p.skillLvl[0] = 150;
         p.getActionSender().setSkillLvl(p, 0);
      p.skillLvl[1] = 150;
         p.getActionSender().setSkillLvl(p, 1);
      p.skillLvl[2] = 150;
         p.getActionSender().setSkillLvl(p, 2);
      } else {
        p.getActionSender().sendMessage(p,"You need to be a Staff member to do this!");
      }
      break;
            case 10394:
                p.requestAnim(5316, 0);
                //p.getActionSender().sendMessage(p, "Nice dancing there");
                break;


            case 773:
                p.requestGFX(385, 100);
                p.requestAnim(7392, 0);
                break;


            case 11283:
                p.DFSSpecial = true;
                break;

           case 7927:
	{
                    int randomInt = Misc.random(6);
                    if (randomInt == 0) {
		p.npcType = 3690;
                    } else if (randomInt == 1) {
		p.npcType = 3691;
                    } else if (randomInt == 2) {
		p.npcType = 3692;
                    } else if (randomInt == 3) {
		p.npcType = 3693;
	    } else if (randomInt == 4) {
		p.npcType = 3694;
                    } else if (randomInt == 5) {
		p.npcType = 3689;
                    }
                p.appearanceUpdateReq = true;
                p.updateReq = true;
	}
		break;
            case 6583:
	p.npcType = 2626;
                p.appearanceUpdateReq = true;
                p.updateReq = true;
		break;

            default:
                Misc.println("[" + p.username + "] Operate item: " + itemId);
                break;
        }
    }
}
